package loginlog

import "time"

/**
 * 登录日志'LoginLog'表结构体
 * 警告:非数据库字段禁止在此添加,应该创建扩展结构体中添加
 * @author HuangXinBian
 */
type LoginLogBase struct {
	GiId         int64     `json:"iId" gorm:"column:iId; type:bigint(20)AUTO_INCREMENT; NOT NULL; primary_key; comment:记录编号"`
	GsName       string    `json:"sName" gorm:"column:sName; type:varchar(32); comment:日志类型(冗余)"`
	GiType       int       `json:"iType" gorm:"column:iType; type:int(11); NOT NULL; DEFAULT:1; comment:日志类型"`
	GsUserId     string    `json:"sUserId" gorm:"column:sUserId; type:varchar(8); comment:用户编号"`
	GsUser       string    `json:"sUser" gorm:"column:sUser; type:varchar(32); comment:用户名(冗余)"`
	GsIp         string    `json:"sIp" gorm:"column:sIp; type:varchar(32); comment:IP地址"`
	GsMACAddress string    `json:"sMACAddress" gorm:"column:sMACAddress; type:varchar(64); comment:MAC地址"`
	GdLogDate    time.Time `json:"dLogDate" gorm:"column:dLogDate; type:datetime; comment:发生时间"`
	GdLastCall   time.Time `json:"dLastCall" gorm:"column:dLastCall; type:datetime; comment:最后访问时间"`
}

/**
 * 初始化
 */
func init() {
}

/**
 * 创建结构实体,并赋予默认值
 */
func (LoginLogBase) New() LoginLogBase {
	return LoginLogBase{
		GiId:         0,
		GsName:       "",
		GiType:       1,
		GsUserId:     "",
		GsUser:       "",
		GsIp:         "",
		GsMACAddress: "",
		GdLogDate:    time.Now(),
		GdLastCall:   time.Now(),
	}
}

/**
 * 设置默认值
 */
func (o *LoginLogBase) SetDefault() {
	o.GiId = 0
	o.GsName = ""
	o.GiType = 1
	o.GsUserId = ""
	o.GsUser = ""
	o.GsIp = ""
	o.GsMACAddress = ""
	o.GdLogDate = time.Now()
	o.GdLastCall = time.Now()
}

/**
 * 结构体映射表名,处理结构体名称与表名不一致的情况
 */
func (LoginLogBase) TableName() string {
	return "LoginLog"
}
